import ij.*;
import ij.process.*;
import java.awt.*;

/**
 * 
 */

/**
 * @author n3
 *
 */
public class J_neuro implements ij.plugin.filter.PlugInFilter {

	@Override
	public void run(ImageProcessor ip) {
		byte[] pixels = (byte[])ip.getPixels();
		int width = ip.getWidth();
		Rectangle r = ip.getRoi();
		
		int offset, i, max;
		max = pixels.length-1;
		for (int y=r.y+r.height-1; y>=(r.y); y--) {
			offset = y*width;
			for (int x=r.x+r.width-1; x>=(r.x); x--) {
					i = offset + x;
					pixels[i] = (byte)(255-pixels[max-i]);
			}
		}
		
	}

	@Override
	public int setup(String arg0, ImagePlus arg1) {
		return DOES_8G+DOES_STACKS+SUPPORTS_MASKING;
	}

}
